$.ready = function()
{
	$('body *').not(':has(input)').not(':has(textarea)').not('input').not('textarea').disableSelection();
	
	$("#tabs").tabs({selected:2});
	
	$(".button").button();
	
	$.elements.prepare();
		
	$.news.prepare();
	
	$("#btnLogout").click(function()
	{
		$.post("./bus/logout.php", null, function(data) {
			$.elements.clear();
			$("#tabs").tabs('select', 0);
			$.welcome.showLogin();			
		});
	});
	
	$.session('user', function(data)
	{
		//Session
		if(data.user != null && data.user.Id > 0)
		{
			$.elements.loadElements();
		}		
		else 
		{
			var email = $.cookie('Email')
			var pass = $.cookie('Password')
		
			if(email != null && pass != null)
			{
				var post = "txtUser=" + email + "&txtPass=" + pass;
				$.welcome.post(post, function(data)
				{
					//Cookie User
					if(data.sucess)
					{
						$.elements.loadElements();
					}
					else
					{
						$.welcome.showLogin();
					}
				});
			}
			else
				$.welcome.showLogin();
		}
	});
}

